﻿using System;
using NUnit.Framework;
using WebServiceUnitTests.SoapTrip;

namespace WebServiceUnitTests
{
    [TestFixture]
    public class TripTests
    {
        [Test]
        public void CreateTripTest()
        {
            FullTripInfo fti = new FullTripInfo();

            fti.Draft = false;

            fti.FreeSeats = 2;
            fti.ID = -1;

            fti.Notes = "note";

            /*
            string depCoords = "43.73426,10.40616"; //Via Giovanni Randaccio 58, Pisa, Italy
            string arrCoords = "41.92476,12.51604"; //Via Eritrea 2, Roma, Italy
            */

            string depCoords = "43.72066,10.407337"; //Via Filippo Buonarroti, Pisa, Italy
            string arrCoords = "41.910285,12.476451"; //Piazza del Popolo, Roma, Italy

            fti.Stages = new StageInfo[1];
            fti.Stages[0] = new StageInfo();
            PlaceInfo depPI = new PlaceInfo() { Coords = depCoords };
            PlaceInfo arrPI = new PlaceInfo() { Coords = arrCoords };
            fti.Stages[0].Origin = depPI;
            fti.Stages[0].Destination = arrPI;

            fti.Stages[0].EstimatedBudget = 100;
            fti.Stages[0].EstimatedTime = 3;

            //A car...
            fti.Stages[0].Vehicle = new VehicleInfo() { Id = 430, VehicleClass = VehicleTypes.Car };

            fti.DepartureDate = new DateTime(2008, 06, 05, 11, 00, 00);
            fti.RepetitionFrequency = 0;
            fti.DeviationRadius = 5000;

            //Uby token
            string authToken = "6940CFE909553A2C9B62A13451A3C6A649FE22989772FA1C40790D426FE2825BA4CCE05DCDCE97DB63B9EA4D6F820A4BC518703B127B443CA7284E4C8EBA1057";

            SoapTripSoapClient client = new SoapTripSoapClient();
            WSInt newId = client.SaveTrip(authToken, fti);
            Console.WriteLine(newId.Payload);
            Assert.IsNotNull(newId);
            Assert.AreEqual("ok", newId.Status);
        }
    }
}
